﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EnCor.Logging
{
    /// <summary>
    /// Main entrance of logging.
    /// </summary>
    public class LogManager
    {
        private static IList<ILogAppender> _Loggers = new List<ILogAppender>();
        private static object Locker = new object();

        /// <summary>
        /// Setup logging module, call Setup only in EnCor.Runtime
        /// </summary>
        /// <param name="loggers"></param>
        internal static void Setup(IList<ILogAppender> loggers)
        {
            lock (Locker)
            {
                _Loggers = loggers;
            }
        }

        /// <summary>
        /// Get Logger with specified name.
        /// </summary>
        /// <param name="loggerName">Logger name</param>
        /// <returns></returns>
        public static ILog GetLogger(string loggerName)
        {
            LoggerWraper wraper = new LoggerWraper(_Loggers);
            return wraper;
        }

        public static ILog Logger
        {
            get
            {
                return new LoggerWraper(_Loggers);
            }
        }
    }
}
